package com.quik.system.taglib;

/**
 * 功能说明：
 * 		  价格处理标签
 * @author jenny
 *
 */
public class PriceTag {
	/**
	 * 输出价格
	 * @param price
	 * @return
	 */
	public static String parsePrice(String price){
		if(price == null || price.length() <= 0)
			return "";
		else if(price.equals("0"))
			return "0.0";
		else{
			int len = price.length();
			return price.substring(0, len-2) + "." + price.substring(len - 2, len);
		}
	}
	
	/**
	 * 计算总价格
	 * @param price
	 * @param num
	 * @return
	 */
	public static String totalPrice(String price, Integer num){
		if(price == null || price.length() <= 0)
			return "";
		
		Integer totalPrice = Integer.parseInt(price);
		totalPrice = totalPrice * num;
		
		String total = String.valueOf(totalPrice);		
		int len = total.length();
		return total.substring(0, len-2) + "." + total.substring(len - 2, len);
	}
}
